<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
    $tip_skin = "tip-" . "yellowsimple";
?>
<html>
    <head>
        <link rel="icon" type="image/png" href="<?php echo img_url(); ?>favicon.png" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title><?php echo $title; ?></title>
        <!--[if lt IE 9]>
            <script src="<?php echo js_url() . "html5shiv.js"; ?>></script>
        <![endif]-->
        <meta name="description" content="<?php echo $description; ?>" />
        <meta name="keywords" content="<?php echo $keywords; ?>" />
        <link href="<?php echo css_url(); ?>bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" media="screen" />    
        <!-- <link href="<?php echo css_url(); ?>bootstrap/css/reset.css" rel="stylesheet" type="text/css" media="screen" />    
        <link href="<?php echo css_url(); ?>bootstrap/css/text.css" rel="stylesheet" type="text/css" media="screen" />    -->
        <!--<link href="<?php echo css_url(); ?>wfaces.css" rel="stylesheet" type="text/css" media="screen" />-->    
        <link href="<?php echo css_url(); ?>chat.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript"  src="<?php echo js_url(); ?>jquery.js">
        </script>
        <script type="text/javascript"  src="<?php echo js_url(); ?>jquery.poshytip.js">
        </script>
        <link href="<?php echo css_url(); ?>tips/<?php echo $tip_skin; ?>/<?php echo $tip_skin; ?>.css" rel="stylesheet" type="text/css" />
        <link href="<?php echo css_url(); ?>bootstrap/datepicker.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript"  src="<?php echo js_url(); ?>/bootstrap-tab.js">
        </script>
        <script type="text/javascript"  src="<?php echo js_url(); ?>datepicker.js">
        </script>
        <link href="<?php echo css_url(); ?>font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
        <!--[if IE 7]>
            <link rel="stylesheet" href="<?php echo img_url(); ?>font-awesome/css/font-awesome-ie7.min.css">
        <![endif]-->
        <link rel="stylesheet" href="<?php echo css_url(); ?>bootstrap-switch.css" />
        <script src="<?php echo js_url(); ?>bootstrap-switch.js"></script>

        <script src="<?php echo js_url(); ?>toggles.min.js"></script>
        <link rel=stylesheet href="<?php echo css_url(); ?>toggles.css" />
        <script>
            var statusUrl = "<?php echo site_url("account/status"); ?>";
            $(document).ready(function() {
                $('#sessionUser').poshytip({
                    className: '<?php echo $tip_skin; ?>',
                    showTimeout: 1,
                    alignTo: 'target',
                    alignX: 'center',
                    fade: false,
                    slide: false,
                    content: $('#tooltip-session').html(),
                    showOn: 'none'
                });

                $('#sessionUser').click(function(e) {
                    $('#sessionUser').poshytip('show');
                    e.stopPropagation();
                    tog();
                });

                $(document).click(function(e) {
                    $('#sessionUser').poshytip('hide');
                });

                $(".<?php echo $tip_skin; ?>").click(function(e) {
                    e.stopPropagation();
                });

                //                $('.foundUserTip').poshytip({
                //                    className: '<?php echo $tip_skin; ?>',
                //                    showTimeout: 1,
                //                    alignTo: 'target',
                //                    alignX: 'center',
                //                    fade: false,
                //                    slide: false,
                //                    content: $('#tipUserF').html(),
                //                    showOn: 'none'
                //                });
            });

        </script>
    </head>

    <body>
        <div id="tooltip-session" style="display: none;">
            <div id="subtooltip" class="subtooltipClass" style="width:200px; height: 60px;">
                <div class='sessionImg'>
                    <img src='<?php echo css_url() . "../pht/" . $user->tof; ?>'/>
                </div>
                <div class='sessionInfos'>
                    <p><?php echo $user->firstname . " " . $user->lastname; ?></p>
                    <p><?php echo $user->city . ", " . $user->country; ?></p>
                    <p><?php echo $user->birthday; ?></p>
                </div>
            </div>
            <div class="infSession">
                <div class="toggle-modern" style="margin-left: 50px;">
                    <!--                    <div style="float:left;">
                                             <i class="icon-off"></i>
                                             Status &nbsp;&nbsp;
                                        </div> -->
                    <div  class="toggle on"></div>
                </div>

                <br/>
                <!--<img src="<?php echo img_url() . "profile.jpg"; ?>" width="15px" height="15px" />-->
                <i class="icon-user"></i>
                &nbsp; 
                <a href="<?php echo site_url("profile"); ?>"> 
                    My Profil
                </a>

                <br/>
                <br/>
                <!--<img src="<?php echo img_url() . "change_pass.png"; ?>" width="15px" height="15px" />-->
                <i class="icon-key" ></i>
                &nbsp; 
                <a href="<?php echo site_url('pass/'); ?>">
                    Change my password
                </a>

                <br/>
                <br/>
                <!--<img src="<?php echo img_url() . "logout.jpg"; ?>" width="15px" height="15px" />-->
                <i class="icon-signout"></i>
                &nbsp; 
                <a href="<?php echo site_url('login/logout'); ?>">
                    Log out
                </a> 

                <br/>
                <br/>
                <!--<img src="<?php echo img_url() . "disable.png"; ?>" width="15px" height="15px" />-->
                <i class="icon-remove-sign"></i>
                &nbsp; 
                <a href="<?php echo site_url('account/'); ?>">
                    Deactivate or delete my account
                </a>

            </div>
        </div>
        <div class="container">
            <div class="row">
                <div class="span12">
                    <div class="span3" style="margin-left:0px">
                        <img class="logo" src="<?php echo img_url() . "wfaces4.1.png"; ?>"/>
                    </div>
                    <div class="span6">
                       
                    </div>
                    <!--                    <div class="span2">
                                            Status :
                                            <div class="label-toggle-switch make-switch switch-mini" data-on="success" data-on-label="Online" data-off-label="Offline">
                                                <input type="checkbox" checked="checked" />
                                            </div>
                                        </div>-->
                    <!--                    <div class="span2">
                    
                                        </div>-->
                    <div class="span3">
                        <div class="row">
                            <div class="span1" style="text-align: right;">
                                <a href="<?php echo site_url("chat/index"); ?>">
                                    Discussion
                                </a>
                            </div>
                            <div id="sessionUser" class="span2">   
                                <a href="#">
                                   <!--<img src="<?php echo css_url("chat/with") . "../pht/" . $user->tof; ?>" width="25px" height="25px" />--> 
                                    <span class="connected-user">
                                        <?php
                                        echo $user->firstname . " " . $user->lastname;
                                        ?>
                                    </span>
                                    <img src="<?php echo img_url() . "arrow.png"; ?>"/>    
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="span12 hr">
                    &nbsp;
                </div>
            </div> 
            <?php
            if (isset($notifs)) {
                ?>
                <div class="row" style="min-height: 20px">
                    <?php $this->load->view($notifs); ?>
                </div>
                <?php
            }
            ?>
            <div class="row">
                <?php
                if (isset($view)) {
                    $this->load->view($view);
                }
                ?>

            </div>
            <div style="height:50px;">
                &nbsp;
            </div>
            <?php
            $this->load->view("templates/footer");
            ?>
        </div>
        <!-- end .container_12 -->
    </body>
    <script type="text/javascript" src="<?php echo js_url(); ?>idle/jquery.idle.min.js"></script>
    <script type="text/javascript">

        var userId = "<?php echo $user->id; ?>";

        function isIdle() {
            $.ajax({
                async: true,
                cache: false,
                type: "POST",
                url: "<?php echo site_url("login/idle"); ?>",
                error: function() {
                    alert("error");
                    //console.log("error occurred");
                },
                success: function(data) {
                    // alert("data=" + data);
                },
                complete: function(d) {
                    //alert("OK");
                }
            });
            //            $( ".statut"+ jSonTable.discussion.to_user.id ).each(function(index) {
            //                $(this).attr("src",imgUrl+jSonTable.discussion.to_user.statut+".png");
            //            });
        }

        function isBack() {
            $.ajax({
                async: true,
                cache: false,
                type: "POST",
                url: "<?php echo site_url("login/back"); ?>",
                error: function() {
                    // alert("error");
                    //console.log("error occurred");
                },
                success: function(data) {
                    //alert("data=" + data);
                },
                complete: function(d) {
                    //alert("OK");
                }
            });
            //            $(".statut" + userId).attr("src", "<?php echo img_url() . "online.png"; ?>");
        }
        
        var on =  <?php echo ($user->offline=="0")?"true":"false"; ?>;

        function tog() {
            $('.toggle').toggles({
                on: on,
                text: {on: 'online', off: 'offline'},
                width: 100, // width used if not set in css
                height: 20 // height if not set in css
            });

// Getting notified of changes, and the new state:
            $('.toggle').on('toggle', function(e, active) {
                if (active) {
                    console.log("ac");
                    force_status(0);
                    on = true;
                } else {
                    force_status(1);
                    console.log("inac");
                    on = false;
                }
            });
        }

        $(document).idle({
            onIdle: function() {
                isIdle();
            },
            onActive: function() {
                isBack();
            },
            idle: 120000
        });

        $(document).ready(function() {
            $(".birthday").datepicker({format: 'dd/mm/yyyy'});
        })

    </script>


</html>

